// pages/Jcbgzljcxm/Jcbgzljcxm.js
import ajax from '../../utils/api.js';
Page({

    /**
     * 页面的初始数据
     */
    data: {
        tCheckReportDetail: {},//检测报告详细
        tEntrustCheckDataitemsList: [],//资料检查项目
        tCheckRelationList: [],//现场检测项目表
        tEntrustCheckDataitemsList:{},//资料检查项目
        tCheckRelationList:{},//现场检测项目表
        tCheckInstrumentList:{},
        tCheckInstrumentList:[],//检测仪器设备项目信息
        daohang: [
            {name: "资料检查项目"},
            {name: "现场检测项目表"},
            {name: "检测仪器设备项目信息"},
            {name: "报告基本信息"}
          ],
          currentActive:0,
          date: '',
          array: ['符合条件'],
          array2: ['整机合格','整机不合格','整机复检合格','整机复检不合格'],
          seleNull:null,
          inputValue:[],
          isUpdateText:false,//判断是否更改input的值
          isDisabled:true,//禁止
    },
    resolveValue:function (e) {
        var tCheckRelationList=this.data.tCheckRelationList
        var index=e.target.dataset.xx
        tCheckRelationList[index].result=e.detail.value
        this.setData({
            tCheckRelationList: tCheckRelationList,
	    })
    },
    resolveValue2(e){
        var tCheckRelationList2=this.data.tCheckRelationList
        var index=e.target.dataset.conclusion
        tCheckRelationList2[index].conclusion=e.detail.value
        this.setData({
            tCheckRelationList2: tCheckRelationList2,
	    })
    },

    // resolveValue0(e){
    //     var tEntrustCheckDataitemsList=this.data.tEntrustCheckDataitemsList
    //     var index=e.target.dataset.remark
    //     tEntrustCheckDataitemsList[index].remark=e.detail.value
    //     this.setData({
    //         tEntrustCheckDataitemsList: tEntrustCheckDataitemsList,
	//     })
    // },
    resolveValue3(e){
        var tCheckInstrumentList=this.data.tCheckInstrumentList
        var index=e.target.dataset.mecname
        tCheckInstrumentList[index].mecName=e.detail.value
        this.setData({
            tCheckInstrumentList: tCheckInstrumentList,
	    })
    },
    resolveValue4(e){
        var tCheckInstrumentList=this.data.tCheckInstrumentList
        var index=e.target.dataset.spec
        tCheckInstrumentList[index].spec=e.detail.value
        this.setData({
            tCheckInstrumentList: tCheckInstrumentList,
	    })
    },
    resolveValue5(e){
        var tCheckInstrumentList=this.data.tCheckInstrumentList
        var index=e.target.dataset.number
        tCheckInstrumentList[index].number=e.detail.value
        this.setData({
            tCheckInstrumentList: tCheckInstrumentList,
	    })
    },
    resolveValue6(e){
        var tCheckInstrumentList=this.data.tCheckInstrumentList
        var index=e.target.dataset.effectivetime
        tCheckInstrumentList[index].effectivetime=e.detail.value
        this.setData({
            tCheckInstrumentList: tCheckInstrumentList,
	    })
    },
    resolveValue7(e){
        var tCheckInstrumentList=this.data.tCheckInstrumentList
        var index=e.target.dataset.condition
        tCheckInstrumentList[index].condition=e.detail.value
        this.setData({
            tCheckInstrumentList: tCheckInstrumentList,
	    })
    },
    zlValue(e){
        var tEntrustCheckDataitemsList=this.data.tEntrustCheckDataitemsList
        var index=e.target.dataset.number
        tEntrustCheckDataitemsList[index].number=e.detail.value
        this.setData({
            tEntrustCheckDataitemsList: tEntrustCheckDataitemsList,
	    })
    },
    zlValue01(e){
        var tEntrustCheckDataitemsList=this.data.tEntrustCheckDataitemsList
        var index=e.target.dataset.project
        tEntrustCheckDataitemsList[index].project=e.detail.value
        this.setData({
            tEntrustCheckDataitemsList: tEntrustCheckDataitemsList,
	    })
    },
    zlValue02(e){
        var tEntrustCheckDataitemsList=this.data.tEntrustCheckDataitemsList
        var index=e.target.dataset.require
        tEntrustCheckDataitemsList[index].require=e.detail.value
        this.setData({
            tEntrustCheckDataitemsList: tEntrustCheckDataitemsList,
	    })
    },
    zlValue03(e){
        var tEntrustCheckDataitemsList=this.data.tEntrustCheckDataitemsList
        var index=e.target.dataset.result
        tEntrustCheckDataitemsList[index].result=e.detail.value
        this.setData({
            tEntrustCheckDataitemsList: tEntrustCheckDataitemsList,
	    })
    },
    zlValue04(e){
        var tEntrustCheckDataitemsList=this.data.tEntrustCheckDataitemsList
        var index=e.target.dataset.remark
        tEntrustCheckDataitemsList[index].remark=e.detail.value
        this.setData({
            tEntrustCheckDataitemsList: tEntrustCheckDataitemsList,
	    })
    },
    toValue(e){
        var _this=this
        var datas = e.detail.value
        datas["id"]=this.data.tCheckReportDetail.id;
        datas=JSON.stringify(datas);
        ajax.gengxbg({
            type:'tCheckReportDetail',
            datas:datas,
        }).then((res)=>{
        } ).catch((err) => {
            });  
    },
    switchNav: function (e){
        var cur = e.currentTarget.dataset.current;                
        this.setData({
            currentActive: cur,
        })      
        if (cur == 3){
            this.xuz()
        }
    },
    bindDateChange: function(e) {
        this.setData({
          date: e.detail.value
        })
      },
      bindDateChange2: function(e) {
        this.setData({
          date: e.detail.value
        })
      },
      bindPickerChange: function(e) {
        this.setData({
        seleNull:'0',
          index: e.detail.value
        })
      },
      bindPickerChange2: function(e) {
        // this.data.array2[e.detail.value].dictname
        this.setData({
        seleNull:'0',
          index: e.detail.value
        })
      },
      jiancexq(){ //获取检测报告详细信息
        var _this=this
        ajax.jcbgxx(this.data.detailId).then((res)=>{
            var  tCheckReportDetail = res.data.tCheckReportDetail;//检测报告详细
            var tEntrustCheckDataitemsList=res.data.tEntrustCheckDataitemsList;//资料检查项目
            var  tCheckRelationList=res.data.tCheckRelationList;//现场检测项目表
            var  tCheckInstrumentList = res.data.tCheckInstrumentList//检测仪器设备项目信息 
            _this.setData({
                tCheckReportDetail:tCheckReportDetail,
                tEntrustCheckDataitemsList:tEntrustCheckDataitemsList,
                tCheckRelationList:tCheckRelationList,
                tCheckInstrumentList:tCheckInstrumentList,
            })
            } ).catch((err) => {
                console.log(err)
              });  
   },
        xuz(){ //检测快报结论
            var _this=this
            ajax.kbjl().then((res)=>{
                var array2 = res.data;
                this.setData({
                    array2:[]
                })
                for(var i =0;i<array2.length;i++){
                    this.data.array2[i]=array2[i].dictname
                    //  this.data.array2[i]=array2[i]
                }
                this.setData({
                    array2:this.data.array2,
                })
            } ).catch((err) => {
                    console.log(err)
                });  
        },
        gengxin(data){ //更新检测报告
            var _this=this
            var tCheckRelationList=this.data.tCheckRelationList
            tCheckRelationList=JSON.stringify(tCheckRelationList);
            ajax.gengxbg({
                type:'tCheckRelationList',
                datas:tCheckRelationList
            }).then((res)=>{
            } ).catch((err) => {
                    console.log(err)
                });  
        },
        gengxin0(data){ //更新检测报告
            var _this=this
            // var tCheckRelationList=this.data.tCheckRelationList
            var tEntrustCheckDataitemsList=this.data.tEntrustCheckDataitemsList
            tEntrustCheckDataitemsList=JSON.stringify(tEntrustCheckDataitemsList);
            ajax.gengxbg({
                type:'tEntrustCheckDataitemsList',
                datas:tEntrustCheckDataitemsList
            }).then((res)=>{
            } ).catch((err) => {
                    console.log(err)
                });  
        },
        
        gengxin3(data){ //更新检测报告
            var _this=this
            // var tCheckRelationList=this.data.tCheckRelationList
            var tCheckInstrumentList=this.data.tCheckInstrumentList
            tCheckInstrumentList=JSON.stringify(tCheckInstrumentList);
            ajax.gengxbg({
                type:'tCheckInstrumentList',
                datas:tCheckInstrumentList
            }).then((res)=>{
            } ).catch((err) => {
                    console.log(err)
                });  
        },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        if (options.id != ''){
            this.setData({
                detailId:options.id,
            })
        }
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        this.jiancexq()
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})